#include <stdio.h>
int main()
{
    int n;
    while (scanf("%d",&n)!=EOF)
    {
        if (n==0)break;
        int a,b=0,i,time=0;
        for (i=0;i<n;i++)
        {
            scanf("%d",&a);
            if (a>b)time=time+(a-b)*6+5;
            else time=time+(b-a)*4+5;
            b=a;
        }
        printf("%d\n",time);
    }
    return 0;
}
